package com.finger.forest;

import android.os.Bundle;
import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.finger.forest.utils.ClickUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 消息编辑
 */
public class NoticeEditActivity extends AppCompatActivity implements View.OnClickListener {

    /**
     * 返回
     */
    @BindView(R.id.btn_back)
    ImageView backIv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notice_edit);
        ButterKnife.bind(this);

        ListView noticeListView = this.findViewById(R.id.listView_notice);

        List<Map<String,Object>> list = new ArrayList<>();

        Map<String,Object> map1 = new ArrayMap<>();
        map1.put("alarmType",R.mipmap.alarm_station);

        Map<String,Object> map2 = new ArrayMap<>();
        map2.put("alarmType",R.mipmap.alarm_enter);

        Map<String,Object> map3 = new ArrayMap<>();
        map3.put("alarmType",R.mipmap.alarm_fire);

        list.add(map1);
        list.add(map2);
        list.add(map3);

        SimpleAdapter simpleAdapter = new SimpleAdapter(NoticeEditActivity.this,list,R.layout.item_notice_edit,
                new String[]{"alarmType"},new int[]{R.id.iv_alarm_type});
        noticeListView.setAdapter(simpleAdapter);
        noticeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ImageView iv = (ImageView)view.findViewById(R.id.iv_select);
                if (iv.getTag().equals("FALSE")){
                    iv.setImageDrawable(getDrawable(R.mipmap.notice_selected));
                    iv.setTag("TRUE");
                }else {
                    iv.setImageDrawable(getDrawable(R.mipmap.notice_unselect));
                    iv.setTag("FALSE");
                }

            }
        });

    }

    @OnClick({R.id.btn_back })
    @Override
    public void onClick(View v) {
        if (ClickUtils.isFastClick()) { //防止重复点击
            switch (v.getId()) {

                //返回
                case R.id.btn_back:
                    finish();
                    break;

                default:
                    break;
            }
        }
    }

}
